﻿using System;
using System.Windows.Forms;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.HCLoad.Import;

namespace YArchitech.HCLoad
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	internal class HcImport : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			Result result;
			try
			{
				ImportForm importForm = new ImportForm(commandData.Application, false);
				if (DialogResult.OK == importForm.ShowDialog())
				{
					result = Autodesk.Revit.UI.Result.Succeeded;
				}
				else
				{
					result = Autodesk.Revit.UI.Result.Cancelled;
				}
			}
			catch (Exception ex)
			{
				message = ex.Message;
				result = Autodesk.Revit.UI.Result.Failed;
			}
			return result;
		}
	}
}
